﻿using System;
using System.Collections.Generic;
using System.Text;
using Utils.Explorer;
using System.Collections;
using MyCollections.Model;
using System.Xml;
using System.Xml.Serialization;
using System.IO;

namespace Utils.Test
{
    class Program
    {
        static void Main(string[] args)
        {
            ArrayList completFileList = Explorer.Tasks.GenerateFileList("G:\\Movies\\", true);

            ArrayList file_types = new ArrayList();
            file_types.Add(".avi");

            ArrayList selectedFileList = Tasks.FilterFileList(completFileList, file_types);
            ArrayList directoryList = Tasks.FilterDirectoryList(completFileList);
            ArrayList filenames = Files.GetFileNames(selectedFileList);
            ArrayList FilesInfo = Files.GetFilesInfo("G:\\Movies\\", ".avi");

            
            //read all file, add to object list and serialize all to xml file
            ArrayList ObjectList = new ArrayList();
            Movie m= new Movie();
            foreach (string str in filenames)
            {
                m = new Movie();
                m.Title = str;
                ObjectList.Add(m);
            }

            IEnumerator ienum = ObjectList.GetEnumerator();
            Collection col = new Collection();
            
            while (ienum.MoveNext())
            {
               m = (Movie)ienum.Current;
               col.addMovie(m);
            }

            col = new Collection();
            foreach (FileInfo f in FilesInfo)
            {
                m = new Movie();
                m.Title = f.Name;
                m.Size = f.Length;
                m.Extension = f.Extension;
                col.addMovie(m);
            }


            /*
             * XmlDocument xmldoc = new XmlDocument();
            xmldoc.InnerXml = IMDB.Tools.getImdbInfoByTitle("PS");
            string s = IMDB.Tools.getImdbInfoById("tt1328242");
             * */



            XML.XML.SaveFile("C:\\collection.xml", col);
            Collection c = (Collection)XML.XML.LoadFile("C:\\collection.xml", typeof(Collection));



            // test ImdbServices.dll

            //Movie m = new Movie();
            //m
        }

        
    }
}
